# Informations
import subprocess
import win32net
import win32api
from _winreg import *

def get_systeminfo():
	process = subprocess.Popen('systeminfo', shell=True, stdout=subprocess.PIPE, stderr=None)  
	output = process.stdout.readlines()  
	outfile = open('infos/systeminfo.txt','w')
	for line in output:
		outfile.write(line)
	outfile.close()

def get_netstat():
	process = subprocess.Popen('netstat -ano', shell=True, stdout=subprocess.PIPE, stderr=None)  
	output = process.stdout.readlines()  
	outfile = open('infos/netstat.txt','w')
	for line in output:
		outfile.write(line)
	outfile.close()

def get_tasklist():
	process = subprocess.Popen('tasklist', shell=True, stdout=subprocess.PIPE, stderr=None)  
	output = process.stdout.readlines()  
	outfile = open('infos/tasklist.txt','w')
	for line in output:
		outfile.write(line)
	outfile.close()

def get_userinfo():
	outfile = open('infos/userinfo.txt','w')
	# get Server Info
	server_name = win32net.NetServerGetInfo(None,100)['name']
	outfile.write('\n===========================================================================================')
	outfile.write('\n\n                    SERVER NAME\t\t: ' + server_name)
	
	# get Group Info
	group_name = win32net.NetGroupEnum(server_name, 0)[0][0]['name']
	outfile.write('\n\n                    GROUP NAME\t\t: ' + group_name)
	# get List User
	list_user = win32net.NetGroupGetUsers(server_name, group_name, 0)
	number_user = win32net.NetGroupGetUsers(server_name, group_name, 0)[1]
	outfile.write('\n\n                    NUMBER OF USER\t: ' + str(number_user))
	outfile.write('\n\n===========================================================================================')
	list_user_item = win32net.NetGroupGetUsers(server_name, group_name, 0)[0]
	current_user_name = win32api.GetUserName()
	for l in list_user_item:
		outfile.write("\n\n--------------------------------------------^-^--------------------------------------------\n\n")
		user_name = l['name']
		if user_name == current_user_name:
			outfile.write("                                         CURRENT USER                                           \n\n")
		process = subprocess.Popen('net user ' + '"' + user_name + '"', shell=True, stdout=subprocess.PIPE, stderr=None)  
		output = process.stdout.readlines()
		for line in output:
			if line != "\r\n":
				outfile.write(line[0:len(line)-2] + "\n")
	outfile.close()

def get_regsys():
	reg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
	key = OpenKey(reg, r'SOFTWARE\Microsoft\Windows NT\CurrentVersion')
	print "Product Name: " + QueryValueEx(key, "ProductName")[0]

def get_firefox():
	
get_regsys()